package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.event.AdministratorEvent;
import com.clas.liu.myapplication.model.impl.BandedUserModel;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.presenter.i.IBandedUserPresenter;
import com.clas.liu.myapplication.view.activity.impl.BandedUserActivity;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;

/**
 * Created by liu on 2019/5/27.
 */

public class BandedUserPresenter extends BasePresenter<BandedUserActivity,BandedUserModel> implements IBandedUserPresenter {
    public BandedUserPresenter(BandedUserActivity view) {
        super(view);
    }

    @Override
    public void getInfo(int page_no, int page_size) {
        mModel.getInfo(page_no,page_size);
    }

    @Override
    public void cancel(int id) {
        mModel.cancel(id);
    }

    @Override
    protected BandedUserModel getModel(Handler handler) {
        return new BandedUserModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case AdministratorEvent.GET_BANDED_USER_OK:
                mView.dataReturn(((AdministratorEvent)msg.obj).getSearchUserRoot().getData());
                break;
            case AdministratorEvent.GET_BANDED_USER_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.CANCEL_BANDED_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.CANCEL_BANDED_OK:
                mView.cancelReturn();
                break;
        }
    }
}
